﻿using System;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace WWF
{
    public class WebForm
    {
        public string Title { get; set; }
        public Size Size { get; set; }
        public Point Location { get; set; }
        public Icon Icon { get; set; }
        public Color BackgroundColor { get; set; }
        public Cursor Cursor { get; set; }
        public bool Visible { get; set; }

        public event MouseEventHandler MouseMove;
        public event PaintEventHandler Paint;
        public event FormClosingEventHandler FormClose;
        public event EventHandler FormLoad;

        #region "Event invokers"

        internal protected void OnMouseMove(MouseEventArgs e)
        {
            if (MouseMove != null)
            {
                MouseMove(this, e);
            }
        }

        internal protected void OnPaint(PaintEventArgs e)
        {
            if (Paint != null)
            {
                Paint(this, e);
            }
        }

        internal protected void OnFormClose(FormClosingEventArgs e)
        {
            if (FormClose != null)
            {
                FormClose(this, e);
            }
        }

        internal protected void OnFormLoad(EventArgs e)
        {
            if (FormLoad != null)
            {
                FormLoad(this, e);
            }
        }

        #endregion

        public WebForm()
        {
            Size = new Size(500, 500);
            Location = new Point(100, 100);
            BackgroundColor = SystemColors.Control;
            Title = "Web Form";
            Cursor = Cursors.Default;
        }

        public void Show()
        {
            Visible = true;

            if (FormLoad != null)
            {
                FormLoad(this, null);
            }
        }

        public void Close()
        {
            Visible = false;

            if (FormClose != null)
            {
                FormClose(this, new FormClosingEventArgs(CloseReason.FormOwnerClosing, true));
            }
        }

    }
}